﻿@model ALinq.BBS.DataAccess.Board
@using System.Web.Mvc.Html
@using ALinq.BBS.App_GlobalResources
@using ALinq.BBS.DataAccess
@{
    Layout = "_Layout.cshtml";

    PageData["Title"] = "Board List";

    var boards = new Boards();

}
<script type="text/javascript">
    function submitForm() {
        document.getElementsByTagName('form')[0].submit();
    }
</script>
@using (Html.BeginForm())
{
    <input name="event" type="hidden" value="delete" />
    <table cellpadding="0" cellspacing="0" style="width: 100%">
        <tr>
            <td class="ListItemHeader_l" style="width: 30px;">
            </td>
            <td class="ListItemHeader_m">
                名称
            </td>
            <td class="ListItemHeader_m" style="width: 80px; text-align: center;">
                论坛数
            </td>
            <td class="ListItemHeader_r" style="width: 120px;">
                &nbsp;
            </td>
        </tr>
        @foreach (var item in boards)
        {
            <tr>
                <td class="ListItem" style="text-align: center">
                </td>
                <td class="ListItem">
                    @if (item.ID == ViewBag.EditItemID)
                    {
                        <input type="text" value="@item.Name" name="Name" />
                    }
                    else
                    {
                        @Html.ActionLink(item.Name, "ForumsList", new { boardID = item.ID })
                    }
                </td>
                <td class="ListItem" style="text-align: center; color: #FF5500">
                    @item.Forums.Count
                </td>
                <td class="ListItem">
                    @if (item.ID == ViewBag.EditItemID)
                    {
                        <input type="hidden" name="ID" value="@item.ID" />
                        <a href="javascript:submitForm()">@Label.Update</a>
                        <span>&nbsp;</span>//updateForm
                        @Html.ActionLink(Label.Cancle, "BoardsList")
                    }
                    else
                    {
                        @Html.ActionLink(Label.Edit, "BoardsList", new { editID = item.ID })
                        if (item.Forums.Count == 0)
                        {
                        <span>&nbsp;</span>
                        @Html.ActionLink(Label.Delete, "BoardsList", new { deleteID = item.ID })
                        }
                    }
                </td>
            </tr>
        }
        @if (ViewBag.EditItemID == null)
        {
            <tr>
                <td class="ListItem" style="text-align: center">
                    <input type="hidden" name="ID" value="0" />
                </td>
                <td class="ListItem">
                    @Html.TextBoxFor(o => o.Name)
                </td>
                <td class="ListItem" style="text-align: center; color: #FF5500">
                    0
                </td>
                <td class="ListItem">
                    <a href="javascript:submitForm()">@Label.Add</a>
                </td>
            </tr>
        }
        <tr>
            <td colspan="4">
                <hr class="spliter" />
            </td>
        </tr>
        <tr>
            <td colspan="4" class="ListItemHeader" style="text-align: right;">
                <input type="submit" value="删除" style="width: 80px;" />
                &nbsp;
            </td>
        </tr>
    </table>
}
